<!DOCTYPE html>
<html>
<head>
	<!-- 公共页面 -->
	#include("../include/common.html")
	<!-- 公共页面 /-->
</head>
<body class="hold-transition skin-purple sidebar-mini">
    <div class="wrapper">
        <!-- 页面头部 -->
        #include("../include/header.html")
        <!-- 页面头部 /-->
        <!-- 导航侧栏 -->
        #include("../include/menu.html")
        <!-- 导航侧栏 /-->
        <!-- 内容区域 -->
        <div class="content-wrapper" id="contentDiv">
            <!-- 正文区域 -->
            <section class="content">
            	<form id="inputForm" action="save" method="post">
				<!--表单信息-->
                <div class="panel panel-default" style="padding-bottom: 10px;">
                    <div class="panel-heading">角色信息</div>
                    <div class="row data-type">
                        <div class="col-md-2 title">角色名称</div>
                        <div class="col-md-10 data">
                            <input type="text" class="form-control" placeholder="角色名称" name="name" value="">
                        </div>
                        <div class="col-md-2 title">角色描述</div>
                        <div class="col-md-10 data">
                            <input type="text" class="form-control" placeholder="角色描述" name="remark" value="">
                        </div>
                        <div class="col-md-2 title">管辖站点</div>
                        <div class="col-md-10 data">
                            <div class="form-group form-inline">
                            	#for(site : sites)
                                <div class="checkbox"><label><input type="checkbox" name="siteIds" value="#(site.id)"> #(site.name)</label></div>
                                #end
                            </div>
                        </div>
                        <div class="col-md-2 title" style="height: auto">权限</div>
                        <div class="col-md-10 data" style="height: auto;">
                        	#for(rootMenu : rootMenus)
                           	#if(rootMenu.type==1)
	                        <div class="form-group form-inline">
	                            <div class="col-md-2"><a href="javascript:;" class="selectAll">#(rootMenu.name)</a></div>
	                            <div class="col-md-10">
	                                 <div class="form-group form-inline">
	                                 	#for(subMenu : rootMenu.children)
                                        <div class="checkbox"><label><input class="checkbox" type="checkbox" name="permissions" value="#(subMenu.url)" />#(subMenu.name)</label></div>
	                                    #end
	                                </div>
	                            </div>
	                        </div>
	                        #else if(rootMenu.type==2)
	                        <div class="form-group form-inline">
	                            <div class="col-md-2"><a href="javascript:;" class="selectAll">#(rootMenu.name)</a></div>
	                            <div class="col-md-10">
	                                 <div class="form-group form-inline">
                                        <div class="checkbox"><label><input class="checkbox" type="checkbox" name="permissions" value="#(rootMenu.url)" />#(rootMenu.name)</label></div>
	                                </div>
	                            </div>
	                        </div>
	                        #end
	                        #end
                        </div>
                    </div>
	                <!--工具栏-->
	                <div class="box-tools text-center">
	                    <button type="submit" class="btn bg-maroon">保存</button>
	                    <button type="button" class="btn bg-default" onclick="history.back(-1);">返回</button>
	                </div>
	                <!--工具栏/-->
                </div>
                <!--表单信息/-->
                </form>
            </section>
            <!-- 正文区域 /-->
        </div>
        <!-- 内容区域 /-->
        <!-- 底部导航 -->
        #include("../include/footer.html")
        <!-- 底部导航 /-->
    </div>
</body>
</html>
<!---->
<script>
 $(document).ready(function() {
     // 激活导航位置
     setSidebarActive("admin-role");
 });
</script>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
    var $selectAll = $("#inputForm .selectAll");
    
    
    
    $selectAll.click(function() {
        var $this = $(this);
        var $thisCheckbox = $this.closest(".form-group").find("input:checkbox");
        if ($thisCheckbox.filter(":checked").size() > 0) {
            $thisCheckbox.prop("checked", false);
        } else {
            $thisCheckbox.prop("checked", true);
        }
        return false;
    });
    
	
	// 表单验证
	$inputForm.validate({
		rules: {
			name:"required"
		}
	});

});
</script>
